﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EventSys.BussinesEntities;

namespace EventSys.Repository
{
    public class RolesRepository:MasterRepository,IRolesRepository
    {
        public List<webpages_Roles> MostrarRoles()
        {
            return Context.webpages_Roles.ToList();
        }

        public webpages_Roles GetRolesById(int id)
        {
            var rol=Context.webpages_Roles.Find(id);
            return rol;
        }

        public void AddRoles(webpages_Roles roles)
        {
            Context.webpages_Roles.Add(roles);
            Context.SaveChanges();
        }

        public void UpdateRoles(webpages_Roles roles)
        {
            Context.Entry(roles).State = System.Data.EntityState.Modified;
            Context.SaveChanges();
        }

        public void RemoveRoles(int id)
        {
            var existe = Context.webpages_Roles.Find(id);

            if (existe != null)
            {
                Context.webpages_Roles.Remove(existe);
                Context.SaveChanges();
            }
        }

        public List<webpages_Roles> GetFromAllRolesByCriterio(string criterio)
        {
            throw new NotImplementedException();
        }
    }
}
